<?php

$server = new swoole_server("0.0.0.0", 9501);

$server->on('connect', function ($server, $fd) {
    echo "链接成功.\n";
});

$server->on('receive', function ($server, $fd, $form_id, $data) {
    $server->send($fd, "自动回复:" . $data);
});

$server->on('close', function ($service, $fd) {
    echo "关闭链接";
});

$server->start();